package com.kdg.fanxing;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 通配符
 * Created by kong on 2018/6/15.
 */
public class TongPei {

    static List<Apple> apples = Arrays.asList(new Apple());
    static List<Fruit> fruits = Arrays.asList(new Fruit());
    static class Reader<T>{
        T readExact(List<? extends T> list){
            if(list != null && list.size()>0){
                return list.get(0);
            }else{
                return null;
            }
        }
    }

    static void f1(){
        Reader<Fruit> fruitReader = new Reader<>();
        fruitReader.readExact(apples);
        List<Fruit> list = new ArrayList<>();
        list.add(new Apple());
        list.add(new Fruit());
        for(Fruit fr:list){
            System.out.println(fr.getClass());
        }
    }

    public static void main(String[] args) {
//        Box<Number> numberBox = new Box<>();
//        numberBox.boxTest(123);
        f1();
    }

}

class Fruit{}
class Apple extends Fruit{}
class Orange extends Fruit{}
